
#include "lexer.hpp"
#include "parser.hpp"
#include <iostream>

using namespace std;

int main()
{
	const string greetings = "Welcome to interactive calculator! :)";
	const string prompt = "calc> ";

	cout << greetings << endl;

	for (;;) {
		cout << prompt;

		string input;
		getline(cin, input);

		try {
			TokenStream ts = Lexer::getTokenStream(input + "\n");
			Result *result = Parser::parse(ts);

			cout << (*result) << endl;

			delete result;

		} catch (const Parser::ParserException &e) {
			cerr << "Parser error" << endl;
		} catch (const Lexer::LexerException &e) {
			cerr << e.what() << endl;
		}

	}
}
